package cn.com.huzo.repository.tech.impl;

import cn.com.huzo.model.entities.tech.ProductBomLinesProductColourEntity;
import cn.com.huzo.repository.tech.ProductBomLinesProductColourRepository;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 成品色数据对象实现。
 *
 * @author 吴旭
 */
@Repository("ProductBomLinesProductColourRepository")
public class ProductBomLinesProductColourRepositoryImpl extends GenericRepositoryImpl<ProductBomLinesProductColourEntity, String>
        implements ProductBomLinesProductColourRepository {

    private final String namespace = "cn.com.huzo.repository.tech.ProductBomLinesProductColourRepository";

    /**
     * 构造函数,设置the entity to UcLinesRepositoryImpl.class.
     */
    public ProductBomLinesProductColourRepositoryImpl() {
        super(ProductBomLinesProductColourEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<ProductBomLinesProductColourEntity> fetchByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchInsert(List<ProductBomLinesProductColourEntity> itemList) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchInsert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertByStyleNo(Long headerId, Long productId) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("ProductId", productId);

        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insertByStyleNo"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer importLinesFromOtherBom(Long headerId, Long importedBomHeaderId) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("ImportedBomHeaderId", importedBomHeaderId);

        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "importLinesFromOtherBom"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchUpdate(List<ProductBomLinesProductColourEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchUpdate"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer updateProductColourOrder(List<ProductBomLinesProductColourEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "updateProductColourOrder"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(String linesKey) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), linesKey);
    }
}
